package com.cw.jeeyt.service.converter.process;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.process.ActDeModelHistoryBo;
import com.cw.jeeyt.dao.model.process.ActDeModelHistoryDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 流程定义历史转换类
 *
 * @author chenw
 * @date 2019-03-10 21:47:04
 */
public class ActDeModelHistoryConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ActDeModelHistoryBo do2Bo(ActDeModelHistoryDo model) {
        if (model == null) {
            return null;
        }
        ActDeModelHistoryBo bo = new ActDeModelHistoryBo();
        bo.setId(model.getId());
        bo.setName(model.getName());
        bo.setModelKey(model.getModelKey());
        bo.setDescription(model.getDescription());
        bo.setModelComment(model.getModelComment());
        bo.setCreated(model.getCreated());
        bo.setCreatedBy(model.getCreatedBy());
        bo.setLastUpdated(model.getLastUpdated());
        bo.setLastUpdatedBy(model.getLastUpdatedBy());
        bo.setRemovalDate(model.getRemovalDate());
        bo.setVersion(model.getVersion());
        bo.setModelEditorJson(model.getModelEditorJson());
        bo.setModelId(model.getModelId());
        bo.setModelType(model.getModelType());
        bo.setTenantId(model.getTenantId());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ActDeModelHistoryDo bo2Do(ActDeModelHistoryBo bo) {
        if (bo == null) {
            return null;
        }
        ActDeModelHistoryDo model = new ActDeModelHistoryDo();
        model.setId(bo.getId());
        model.setName(bo.getName());
        model.setModelKey(bo.getModelKey());
        model.setDescription(bo.getDescription());
        model.setModelComment(bo.getModelComment());
        model.setCreated(bo.getCreated());
        model.setCreatedBy(bo.getCreatedBy());
        model.setLastUpdated(bo.getLastUpdated());
        model.setLastUpdatedBy(bo.getLastUpdatedBy());
        model.setRemovalDate(bo.getRemovalDate());
        model.setVersion(bo.getVersion());
        model.setModelEditorJson(bo.getModelEditorJson());
        model.setModelId(bo.getModelId());
        model.setModelType(bo.getModelType());
        model.setTenantId(bo.getTenantId());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ActDeModelHistoryBo> doList2BoList(List<ActDeModelHistoryDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ActDeModelHistoryConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ActDeModelHistoryDo> boList2DoList(List<ActDeModelHistoryBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ActDeModelHistoryConverter::bo2Do));
    }
}